package com.boge.consumer.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class UserController {

    @Value("${service-url.nacos-user-service}")
    private String serverURL;

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/helloConsumer")
    public String helloProvider(){
        System.out.println("------消费者接口执行了-----");
        // 通过RestTemplate 实现 服务的发现和调用
        return restTemplate.getForObject(serverURL+"/hello",String.class);
    }
}
